import { requestClient } from '#/api/request';

/**
 * 首页- 查询客户总数,在服数量,活跃数量,停用数量,休眠数量
 */
export function queryCustomerActivity() {
  return requestClient.get('/hm/statistics/queryCustomerActivity', {});
}

/**
 * 首页- 查询各主产品的库存数量、店铺数量、各主产品当月提货数量
 * @param params
 */
export function queryProductActivity(params?: any) {
  return requestClient.get('/hm/statistics/queryProductActivity', { params });
}

/**
 * 首页- 销售金额Echarts
 */
export function querySaleNumOrMoney(params?: any) {
  return requestClient.get('/hm/statistics/querySaleNumOrMoney', { params });
}

/**
 * 首页- 店铺销售排名
 */
export function queryDeptList(params?: any) {
  return requestClient.get('/hm/statistics/queryDeptList', { params });
}

/**
 * 首页- 主产品单品各店销售排名
 */
export function selectProductSort(params?: any) {
  return requestClient.get('/hm/statistics/selectProductSort', { params });
}

/**
 * 首页- 个人销量排名
 */
export function selectPersonSort(params?: any) {
  return requestClient.get('/hm/statistics/selectPersonSort', { params });
}

/**
 * 首页- 个人服务人员数量排名
 */
export function selectPersonServerSort(params?: any) {
  return requestClient.get('/hm/statistics/selectPersonServerSort', { params });
}

/**
 * @description 获取回款详情数据
 * @param params - 包含type, id, date, productId等
 */
export function getHomeDataDetail(params: {
  date: string;
  id: number;
  productId?: number;
  type: string;
}) {
  return requestClient.get('/hm/statistics/getHomeDataDetail', { params });
}

/**
 * @description 首页-查询退款退货统计和明细
 * @param params - 包含 store (店铺ID), date (YYYY或YYYY-MM), mode (year或month)
 */
export function queryRefundAndReturnStats(params?: {
  date: string; // YYYY 或 YYYY-MM
  dateMode: string; // year 或 month
  salespersonId?: string; // 销售人员 ID
  storeId?: string; // 店铺ID，'all'表示全部
}) {
  return requestClient.get('/hm/statistics/queryRefundAndReturnStats', {
    params,
  });
}
